# -*- coding: utf-8 -*-
"""
@Time: 2025/1/10 11:42
@Auth: Zhang Hongxing
@File: scoring_service.py
@Note:   
"""
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/read_text', methods=['POST'])
def read_text():
    # 获取请求中的文件路径
    data = request.json
    file_path = data.get('file_path', '')

    if not file_path:
        return jsonify({'error': 'file_path is required'}), 400

    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            raw_text = f.read()
    except Exception as e:
        return jsonify({'error': str(e)}), 500

    res = {
        'raw_text': raw_text
    }
    return jsonify(res)

if __name__ == '__main__':
    app.run(debug=True)